fix(react-table): type aggregatedCell against bound cellComponents in createAppColumnHelper - #6584
Conversation
… createAppColumnHelper The `App*` column definition types produced by `createAppColumnHelper` enhanced only `cell`, `header`, and `footer` with the registered `cellComponents` / `headerComponents`. `aggregatedCell` (added by `rowAggregationFeature`) was left with its core type, so its render prop `cell` did not expose the bound components the way `cell` does. Add `aggregatedCell` to the omitted keys and re-declare it mirroring `cell` (it shares the cell context) in `AppColumnDefBase`, `AppDisplayColumnDef`, and `AppGroupColumnDef`. Type-only change. Fixes TanStack#6583
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe React Table column definition types now support ChangesAggregated cell typing
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Aggregated-cell render props now expose registered cell components consistently with other column render props, resolving the TypeScript limitation without changing runtime behavior. No current merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
createAppColumnHelper(fromcreateTableHook) returns column-definition types whose render props are enhanced with the registeredcellComponents/headerComponents, so you can writecell: ({ cell }) => <cell.MyCell />. This worked forcell,header, andfooter, but not foraggregatedCell: inside it thecellrender prop was the plain coreCell, with no bound components, so({ cell }) => <cell.MyCell />was a type error.Fixes #6583
Cause
AppColumnDefBase(and its siblingsAppDisplayColumnDef/AppGroupColumnDef)Omitthe corecell | header | footerkeys and re-declare them against the enhancedAppCellContext/AppHeaderContext.aggregatedCell— contributed byrowAggregationFeatureand typed against the cell context, exactly likecell— was never part of that omit-and-enhance set, so it retained its core type.Fix
Add
'aggregatedCell'to the omitted keys and re-declare it mirroringcell(both share the cell context) inAppColumnDefBase,AppDisplayColumnDef, andAppGroupColumnDef. This is a type-only, localized change; the runtime column helper is untouched (components are still bound at render time). JSDoc that enumerates the bound contexts was updated to mentionaggregatedCell.Testing
packages/react-table/tests/createAppColumnHelper.test-d.tsx, a type-level test (checked bytscviatest:types, excluded from the vitest run by its.test-d.name) assertingaggregatedCellaccepts a bound component name acrossaccessor/display/group, with a@ts-expect-errorguard that an unregistered component is still rejected. Confirmed it fails before the fix and passes after.pnpm --filter @tanstack/react-table test:types→ passes.pnpm --filter @tanstack/react-table test:lib→ 6 files, 34 tests passing.Summary by CodeRabbit
New Features
Tests